<?php
/***
 * @name : 牌号厂家api
 * @Class : BrandAction
 * @Author : yu
 * @Create : 2017-2-14
 * @copyright : Fiidee.Monda.Cn
 */
namespace admin\action;

use herosphp\bean\Beans;
use herosphp\http\HttpRequest;
use herosphp\utils\AjaxResult;
use api\utils\SaasApiClient;

/**--tmpl-use--**/
class BrandAction extends CommonAction
{


    /**
     * 牌号
     * @param $member_id 会员id
     * @return AjaxResult
     */
    public function index(HttpRequest $request)
    {

        $page = $request->getParameter('page');
        $pagesize = $request->getParameter('pagesize');

        if ($page <= 0) $page = 1;
        if ($pagesize <= 0) $pagesize = 15;
        $this->page=$page;
        $this->pagesize=$pagesize;

        $search_arr=array(
            'saas_user_id'=>$this->loginUser->getSaasUserId(),

        );
        $service = Beans::get('brand.brand.service');

        $result = $service->getItems($pagesize,$page,array('addtime'=>'-1'),$search_arr);
        $this->generatePageMenu($result['total']);

        $this->assign('items', $result['items']);
        $this->assign('breadcrumb', array('牌号管理', '牌号列表'));
        $this->setView("brand/brand_index");
    }

    public function getCache($key)
    {
        $cache = CacheFactory::create();
        $data = $cache->get($key);

        if (!$data) {
            $cache->set($key, $data, 60 * 5);
        }
        return $data;
    }


    public function setCache($data, $key)
    {
        $cache = CacheFactory::create();
        $cache->set($key, $data, 60 * 5);
    }


}
